﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
</head>
<body>
    <div> 
            <table>
                <tr>
                    <td>Usuario</td>
                    <td><input type="text" id="loginUser" /></td>
                </tr>
                <tr>
                    <td>Password</td>
                    <td><input type="password" id="passwordUser" /></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="button" id="btnIngresarLogin" value="Ingresar al Sistema" onclick="javascript:IngresarSistema();" />
                    </td>
                </tr>
            </table>
    </div>
</body>
</html>
<script type="text/javascript">
    var uriAccederSistema = '@Url.Action("AccederSistema", "Security")';
    var uriPrimeraPagina = '@Url.Action("Index", "Home")';
    function IngresarSistema() {
        $.ajax({
            url: uriAccederSistema,
            type: "POST",
            data: "{'usuario': '" + $("#loginUser").val() + "', 'password': '" + $("#passwordUser").val() + "'}",
            contentType: "application/json",
            success: function (result) {
                if (result.rpt == "1") {
                    document.location.href = uriPrimeraPagina;
                } else {
                    alert(result.mensaje)
                }
            },
            error: function () { alert("Error en el login"); }
        });
    }

</script>
